machineID=1

URL ="http://localhost:8080/rssrest/res/helloworld/killprocess"
Wscript.Echo "" & URL
Set http = CreateObject("MSXML2.XmlHttp")
http.open "GET", URL , FALSE
http.setRequestHeader "Content-Type","'application/soap+xml; charset=utf-8"
http.setRequestHeader "Content-Length", "255"
http.send "null"
Wscript.Echo "http readyState" & http.readyState
Wscript.Echo "http status " & http.status
respo=http.responseText
Wscript.Echo "respnse=" & respo

if respo="" then 
	Wscript.Sleep(1000*60)
else
	parse respo
end if

function parse(response)
'response="1,788|2,734|3,475237|4,1600|5,768"
if response="" then 
	Wscript.Echo "response has no value"
else
	CharacterCount = Len(response) - Len(Replace(response, "|", ""))
	
	col = split(response, "|")
	for i=0 to 	CharacterCount 
	comma = split(col(i), ",")
		 killprocess comma(1)
		 
	next
end if
end function
function killprocess(pid)
flag=0
    set colProcesses = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from Win32_Process Where ProcessId=" & pid )
    if colProcesses.count <> 0 then
        for each objProcess in colProcesses
           objProcess.Terminate()  
		   Wscript.Echo "kill process"
		   status comma(0)
        next
    end if
	killprocess=flag
end function

function status(kid)

Wscript.Echo "ok" & kid

URL ="http://localhost:8080/rssrest/res/helloworld/killprocessstatus" & "?" & "kid=" & kid & "&" & "machineID=" & machineID
Wscript.Echo "" & URL
Set http = CreateObject("MSXML2.XmlHttp")
http.open "GET", URL , FALSE
http.setRequestHeader "Content-Type","'application/soap+xml; charset=utf-8"
http.setRequestHeader "Content-Length", "255"
http.send "null"
Wscript.Echo "http readyState" & http.readyState
Wscript.Echo "http status " & http.status
respose=http.responseText
Wscript.Echo "respnse=" & response

end function

